<html>
<head><meta charset="utf-8"><title>lazy normalization example · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html">lazy normalization example</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="194004662"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194004662" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194004662">(Apr 15 2020 at 09:29)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="c1">// check-pass</span>
<span class="cp">#![feature(const_generics)]</span><span class="w"></span>
<span class="c1">//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash</span>

<span class="k">struct</span> <span class="nc">A</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="p">(</span><span class="kt">usize</span><span class="p">);</span><span class="w"></span>

<span class="k">trait</span><span class="w"> </span><span class="n">Foo</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">foo</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="p">(</span><span class="o">&amp;</span><span class="bp">self</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="p">[</span><span class="n">T</span><span class="p">;</span><span class="w"> </span><span class="n">N</span><span class="p">];</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">impl</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Foo</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">T</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">foo</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="p">(</span><span class="o">&amp;</span><span class="bp">self</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="p">[</span><span class="n">T</span><span class="p">;</span><span class="w"> </span><span class="n">N</span><span class="p">]</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">todo</span><span class="o">!</span><span class="p">()</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>


<span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="p">().</span><span class="n">foo</span>::<span class="o">&lt;</span><span class="p">{</span><span class="w"> </span><span class="mi">2</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">3</span><span class="w"> </span><span class="p">}</span><span class="o">&gt;</span><span class="p">();</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>


<p>Does that need lazy nomalization?</p>



<a name="194004812"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194004812" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194004812">(Apr 15 2020 at 09:30)</a>:</h4>
<p>or rather, should it? It doesn't work at all rn  as type dependent const args aren't supported yet</p>



<a name="194023383"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194023383" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194023383">(Apr 15 2020 at 12:44)</a>:</h4>
<p>no</p>



<a name="194023418"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194023418" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194023418">(Apr 15 2020 at 12:44)</a>:</h4>
<p>lazy normalization is mostly about <code>ParamEnv</code>s</p>



<a name="194023440"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194023440" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194023440">(Apr 15 2020 at 12:44)</a>:</h4>
<p>and the constant being in its own <code>tcx.param_env(def_id)</code></p>



<a name="194023551"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194023551" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194023551">(Apr 15 2020 at 12:45)</a>:</h4>
<p>so that would require <code>{2+3}</code> to be written in <code>main</code>'s <code>where</code> clauses, I think?</p>



<a name="194023659"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194023659" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194023659">(Apr 15 2020 at 12:46)</a>:</h4>
<p>the process here, with the new plan, is that <code>().foo(...)</code> is resolved to <code>Foo::foo</code> (the <code>impl</code> <em>doesn't matter</em>)</p>



<a name="194023701"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194023701" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194023701">(Apr 15 2020 at 12:47)</a>:</h4>
<p>then the <code>DefId</code> of the <code>const N</code> <em>in the trait</em> will be placed in <code>ConstKind::Unevaluated</code></p>



<a name="194023844"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194023844" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194023844">(Apr 15 2020 at 12:48)</a>:</h4>
<p>and from there it propagates through <code>const_eval</code> -&gt; miri -&gt; MIR building -&gt; <code>typeck_tables_of</code></p>



<a name="194063023"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194063023" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194063023">(Apr 15 2020 at 17:16)</a>:</h4>
<blockquote>
<p>then the DefId of the const N in the trait will be placed in ConstKind::Unevaluated</p>
</blockquote>
<p>This doesn't quite work, as it breaks diagnostics. and causes errors when trying to generate mir.</p>
<div class="codehilite"><pre><span></span><span class="n">error</span><span class="p">[</span><span class="n">E0080</span><span class="p">]</span>: <span class="nc">evaluation</span><span class="w"> </span><span class="n">of</span><span class="w"> </span><span class="n">constant</span><span class="w"> </span><span class="n">value</span><span class="w"> </span><span class="n">failed</span><span class="w"></span>
<span class="w">  </span><span class="o">-</span>-&gt; <span class="o">/</span><span class="n">home</span><span class="o">/</span><span class="n">programming</span><span class="o">/</span><span class="n">rust</span><span class="o">/</span><span class="n">src</span><span class="o">/</span><span class="n">test</span><span class="o">/</span><span class="n">ui</span><span class="o">/</span><span class="k">const</span><span class="o">-</span><span class="n">generics</span><span class="o">/</span><span class="n">slice</span><span class="o">-</span><span class="k">const</span><span class="o">-</span><span class="n">param</span><span class="p">.</span><span class="n">rs</span>:<span class="mi">10</span>:<span class="mi">34</span><span class="w"></span>
<span class="w">   </span><span class="o">|</span><span class="w"></span>
<span class="n">LL</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">function_with_bytes</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">BYTES</span>: <span class="kp">&amp;</span><span class="nb">&#39;static</span><span class="w"> </span><span class="p">[</span><span class="kt">u8</span><span class="p">]</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="kp">&amp;</span><span class="nb">&#39;static</span><span class="w"> </span><span class="p">[</span><span class="kt">u8</span><span class="p">]</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">   </span><span class="o">|</span><span class="w">                                  </span><span class="o">^^^^^</span><span class="w"> </span><span class="n">could</span><span class="w"> </span><span class="n">not</span><span class="w"> </span><span class="n">load</span><span class="w"> </span><span class="n">MIR</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">DefId</span><span class="p">(</span><span class="mi">0</span>:<span class="mi">6</span><span class="w"> </span><span class="o">~</span><span class="w"> </span><span class="n">slice_const_param</span><span class="p">[</span><span class="mi">317</span><span class="n">d</span><span class="p">]</span>::<span class="n">function_with_bytes</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>::<span class="n">BYTES</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span><span class="w"></span>
</pre></div>


<p>I am currently working on a slightly different approach which looks at least somewhat promising <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span></p>



<a name="194063273"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194063273" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194063273">(Apr 15 2020 at 17:18)</a>:</h4>
<p>what do you mean?</p>



<a name="194063286"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194063286" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194063286">(Apr 15 2020 at 17:19)</a>:</h4>
<p>there is no other way AFAIK</p>



<a name="194064503"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194064503" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194064503">(Apr 15 2020 at 17:29)</a>:</h4>
<blockquote>
<p>there is no other way AFAIK</p>
</blockquote>
<p>I avoid calling <code>type_of</code> for consts. Not sure if it will work but it's a great way to familiarize myself with the compiler <span aria-label="thinking" class="emoji emoji-1f914" role="img" title="thinking">:thinking:</span> <br>
tbh it's a bodge on top of a bodge rn, so I still have a lot of cleanup to do</p>



<a name="194065057"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194065057" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194065057">(Apr 15 2020 at 17:31)</a>:</h4>
<p>you have to pass that data down</p>



<a name="194065097"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194065097" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194065097">(Apr 15 2020 at 17:31)</a>:</h4>
<p>through miri, through all the MIR stuff, through MIR building, through typeck</p>



<a name="194065237"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194065237" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194065237">(Apr 15 2020 at 17:32)</a>:</h4>
<blockquote>
<p>through miri, through all the MIR stuff, through MIR building, through typeck</p>
</blockquote>
<p>aye</p>



<a name="194223521"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194223521" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194223521">(Apr 15 2020 at 20:33)</a>:</h4>
<p><span class="user-mention" data-user-id="121053">@varkor</span>  I currently emit errors twice. When const evaluating const args, </p>
<p>I can either call <code>typeck_tables_of</code> here, causing cycle errors,<br>
or <code>typeck_tables_of_const_arg</code>(a varsion of <code>typeck_tables_of</code> which correctly handles const args), which emits the same errors as <code>typeck_tables_of</code> without "caching" its result for <code>typeck_tables_of</code>. Causing a later call to <code>typeck_tables_of</code> to emit the same errors once more. <br>
Any idea on how I might solve this?</p>
<p><a href="https://github.com/rust-lang/rust/blob/835428c35d785733e72bfbf32fc2f8fff3e50e63/src/librustc_mir/const_eval/eval_queries.rs#L297" title="https://github.com/rust-lang/rust/blob/835428c35d785733e72bfbf32fc2f8fff3e50e63/src/librustc_mir/const_eval/eval_queries.rs#L297">https://github.com/rust-lang/rust/blob/835428c35d785733e72bfbf32fc2f8fff3e50e63/src/librustc_mir/const_eval/eval_queries.rs#L297</a></p>



<a name="194223655"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194223655" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194223655">(Apr 15 2020 at 20:34)</a>:</h4>
<p>my suggestion was to have <code>typeck_tables_of</code><em>for const args</em> look up the right <code>DefId</code> and <em>then</em> use the right <code>typeck_tables_of_const_arg</code> invocation</p>



<a name="194223685"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194223685" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194223685">(Apr 15 2020 at 20:34)</a>:</h4>
<p>so that it's only ever type-checked once</p>



<a name="194334155"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194334155" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194334155">(Apr 16 2020 at 16:48)</a>:</h4>
<blockquote>
<p>This doesn't quite work, as it breaks diagnostics. and causes errors when trying to generate mir.</p>
</blockquote>
<p>We can add an <code>Option&lt;LocalDefId&gt;</code>to <code>ConstKind::Unevaluated</code> without changing its size.<br>
Considering that we only need to typeck local methods, we can store the <code>DefId</code> of the arg as a <code>LocalDefId</code> which we now use for diagnostics and in places where using the <code>DefId</code> of the param fails.</p>
<p><span class="user-mention" data-user-id="119009">@eddyb</span> Is there a danger of breaking incremental/cross crate queries with this?</p>



<a name="194334245"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194334245" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194334245">(Apr 16 2020 at 16:49)</a>:</h4>
<p>don't be worried about increasing the size</p>



<a name="194334264"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194334264" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194334264">(Apr 16 2020 at 16:49)</a>:</h4>
<p>and the called method could be in another crate, so <code>LocalDefId</code> is not appropriate</p>



<a name="194334457"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194334457" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194334457">(Apr 16 2020 at 16:51)</a>:</h4>
<blockquote>
<p>and the called method could be in another crate, so LocalDefId is not appropriate</p>
</blockquote>
<p>I store the used argument as a localdefid, shouldn't that one be local?</p>



<a name="194335921"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194335921" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194335921">(Apr 16 2020 at 17:01)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@Bastian Kauschke</span> but that's already there</p>



<a name="194335932"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194335932" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194335932">(Apr 16 2020 at 17:01)</a>:</h4>
<p>it's the <code>DefId</code></p>



<a name="194335957"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194335957" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194335957">(Apr 16 2020 at 17:01)</a>:</h4>
<p>or do you mean you're doing something super sneaky?</p>



<a name="194336032"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194336032" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194336032">(Apr 16 2020 at 17:02)</a>:</h4>
<p>where you're storing the param def_id in the <code>DefId</code></p>



<a name="194336053"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194336053" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194336053">(Apr 16 2020 at 17:02)</a>:</h4>
<p>and the true <code>DefId</code> in the <code>LocalDefId</code></p>



<a name="194336066"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194336066" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194336066">(Apr 16 2020 at 17:02)</a>:</h4>
<blockquote>
<p>where you're storing the param def_id in the DefId</p>
</blockquote>
<p>yes</p>



<a name="194336083"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194336083" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194336083">(Apr 16 2020 at 17:02)</a>:</h4>
<p>but even then that's not correct because we need to serialize unevaluated constants cross-crate anyway</p>



<a name="194336172"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194336172" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194336172">(Apr 16 2020 at 17:03)</a>:</h4>
<p>........ why? <span aria-label="shock" class="emoji emoji-1f628" role="img" title="shock">:shock:</span></p>



<a name="194336206"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194336206" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194336206">(Apr 16 2020 at 17:03)</a>:</h4>
<p>because they can be in a type</p>



<a name="194336230"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194336230" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194336230">(Apr 16 2020 at 17:03)</a>:</h4>
<p>there's no reason to think anything will force their normalization</p>



<a name="194336369"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194336369" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194336369">(Apr 16 2020 at 17:04)</a>:</h4>
<p>just make <code>Unevaluated</code> larger :P</p>



<a name="194336382"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194336382" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194336382">(Apr 16 2020 at 17:04)</a>:</h4>
<p>hmm, I could resubstitute the <code>DefId</code> using the <code>LocalDefId</code> during serialization <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span> I doubt this would ever surprise someone</p>



<a name="194336502"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194336502" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194336502">(Apr 16 2020 at 17:05)</a>:</h4>
<p>you'll just waste your own time if you don't do this the easy way</p>



<a name="194336517"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194336517" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194336517">(Apr 16 2020 at 17:05)</a>:</h4>
<blockquote>
<p>just make Unevaluated larger :P</p>
</blockquote>
<p>PREMATURE OPTIMIZATION</p>



<a name="194349264"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194349264" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194349264">(Apr 16 2020 at 18:40)</a>:</h4>
<blockquote>
<p>just make Unevaluated larger :P</p>
</blockquote>
<p>We can actually use <code>DefId</code> and still not change the size <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span></p>



<a name="194349289"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194349289" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194349289">(Apr 16 2020 at 18:40)</a>:</h4>
<p>please I beg you</p>



<a name="194349356"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194349356" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194349356">(Apr 16 2020 at 18:41)</a>:</h4>
<p>first get it working, then worry about size penalties (if they even matter)</p>



<a name="194351056"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194351056" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194351056">(Apr 16 2020 at 18:54)</a>:</h4>
<p>I do <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span> Was just suprised that usng a <code>DefId</code> didn't actually break the static assert</p>



<a name="194351097"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194351097" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194351097">(Apr 16 2020 at 18:54)</a>:</h4>
<p>oh you mean adding a <code>DefId</code> doesn't change the size?</p>



<a name="194351110"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194351110" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194351110">(Apr 16 2020 at 18:54)</a>:</h4>
<p>Yes</p>



<a name="194351129"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194351129" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194351129">(Apr 16 2020 at 18:54)</a>:</h4>
<p>it's <code>(u32, u32)</code></p>



<a name="194351147"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194351147" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194351147">(Apr 16 2020 at 18:55)</a>:</h4>
<p>so the same size as a pointer</p>



<a name="194351207"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194351207" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194351207">(Apr 16 2020 at 18:55)</a>:</h4>
<p>jup, I thought it Unevaluated was the biggest variant and 8 byte aligned</p>



<a name="194351211"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194351211" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194351211">(Apr 16 2020 at 18:55)</a>:</h4>
<p>one of the <code>ConstValue</code> cases has an <code>u128</code>, I wonder if <code>ConstValue</code> is the largest variant of <code>ConstKind</code> :P</p>



<a name="194351449"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194351449" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194351449">(Apr 16 2020 at 18:57)</a>:</h4>
<p>yes, we may try to split data into 2 u64</p>



<a name="194351466"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194351466" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194351466">(Apr 16 2020 at 18:57)</a>:</h4>
<p><a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/interpret/enum.Scalar.html" title="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/interpret/enum.Scalar.html">https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir/interpret/enum.Scalar.html</a></p>



<a name="194351511"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194351511" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194351511">(Apr 16 2020 at 18:57)</a>:</h4>
<p>Alignment costs so much there</p>



<a name="194351517"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194351517" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194351517">(Apr 16 2020 at 18:57)</a>:</h4>
<p>OH I forgot about the <code>u8</code> haha</p>



<a name="194351632"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194351632" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194351632">(Apr 16 2020 at 18:58)</a>:</h4>
<p>although, no, just the fact that <code>Scalar</code> is an <code>enum</code> by itself makes it 24 bytes</p>



<a name="194351726"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194351726" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194351726">(Apr 16 2020 at 18:59)</a>:</h4>
<p>that means <code>ConstValue</code> is 32 bytes</p>



<a name="194351764"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194351764" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194351764">(Apr 16 2020 at 18:59)</a>:</h4>
<p>which is enough for 2 <code>DefId</code>'s, a <code>SubstsRef</code> and an <code>Option&lt;Promoted&gt;</code></p>



<a name="194352100"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194352100" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194352100">(Apr 16 2020 at 19:01)</a>:</h4>
<p>afaict it should be possible to get scalar down to 24 bytes with alignment 8. which should allow us to keep ConstKind smaller as well.<br>
Don't know if this is that useful though <span aria-label="shrug" class="emoji emoji-1f937" role="img" title="shrug">:shrug:</span></p>



<a name="194352140"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194352140" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194352140">(Apr 16 2020 at 19:02)</a>:</h4>
<p><code>Scalar</code> <em>is</em> 24 bytes</p>



<a name="194352194"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194352194" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194352194">(Apr 16 2020 at 19:02)</a>:</h4>
<p>at least that's what it looks like to me</p>



<a name="194352223"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194352223" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194352223">(Apr 16 2020 at 19:02)</a>:</h4>
<p><code>u128</code> can't have alignment of 16 I don't think</p>



<a name="194352310"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194352310" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194352310">(Apr 16 2020 at 19:03)</a>:</h4>
<p>it actually isn't. It's 8</p>



<a name="194352334"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194352334" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194352334">(Apr 16 2020 at 19:03)</a>:</h4>
<p>mb, remembered it wrong</p>



<a name="194352360"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194352360" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194352360">(Apr 16 2020 at 19:03)</a>:</h4>
<p><code>ConstValue</code> isn't and maybe could be 24 bytes</p>



<a name="194352380"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194352380" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194352380">(Apr 16 2020 at 19:03)</a>:</h4>
<p>ah I see</p>



<a name="194352508"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194352508" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194352508">(Apr 16 2020 at 19:04)</a>:</h4>
<p><code>ConstValue</code> with size 24 is possible (or is it...) It is by abusing <code>Allocation</code> alignment <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span></p>



<a name="194353348"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194353348" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194353348">(Apr 16 2020 at 19:11)</a>:</h4>
<p>How relevant is the size of <code>Const</code>s?</p>



<a name="194353535"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194353535" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194353535">(Apr 16 2020 at 19:12)</a>:</h4>
<p>idk, ask <span class="user-mention" data-user-id="120989">@Nicholas Nethercote</span></p>



<a name="194376162"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194376162" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> njn <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194376162">(Apr 16 2020 at 22:32)</a>:</h4>
<p>For all the types I've encountered where the size matters, I have added a <code>static_assert_size!</code> and a comment about it, like this: <a href="https://github.com/rust-lang/rust/blob/3712e11a828af2eea273a3e7300115e65833fbc5/src/librustc_infer/traits/mod.rs#L59-L61" title="https://github.com/rust-lang/rust/blob/3712e11a828af2eea273a3e7300115e65833fbc5/src/librustc_infer/traits/mod.rs#L59-L61">https://github.com/rust-lang/rust/blob/3712e11a828af2eea273a3e7300115e65833fbc5/src/librustc_infer/traits/mod.rs#L59-L61</a></p>



<a name="194376214"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194376214" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> njn <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194376214">(Apr 16 2020 at 22:32)</a>:</h4>
<p>Both <code>Scalar</code> and <code>ConstValue</code> have <code>static_assert_size!</code>, but they lack that comment, which indicates that I didn't add the assertions.</p>



<a name="194376341"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194376341" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> njn <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194376341">(Apr 16 2020 at 22:34)</a>:</h4>
<p><code>git blame</code> will be useful here to work out who added the assertions and why</p>



<a name="194376675"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194376675" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194376675">(Apr 16 2020 at 22:38)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/commit/2a1748834e80b2461be4e18d420503d60e687312" title="https://github.com/rust-lang/rust/commit/2a1748834e80b2461be4e18d420503d60e687312">https://github.com/rust-lang/rust/commit/2a1748834e80b2461be4e18d420503d60e687312</a></p>



<a name="194427269"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194427269" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194427269">(Apr 17 2020 at 11:43)</a>:</h4>
<p>Big progress <span aria-label="sparkles" class="emoji emoji-2728" role="img" title="sparkles">:sparkles:</span> Now fails with a 460 stackframes deep backtrace</p>



<a name="194437887"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194437887" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194437887">(Apr 17 2020 at 13:16)</a>:</h4>
<p>f <code>thread 'rustc' panicked at 'attempt to read from stolen value', /home/programming/rust/src/librustc_middle/ty/steal.rs:42:9</code></p>



<a name="194443846"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194443846" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194443846">(Apr 17 2020 at 13:58)</a>:</h4>
<p>What is the intended use of <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_ast/ast/enum.TyKind.html#variant.Typeof" title="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_ast/ast/enum.TyKind.html#variant.Typeof">https://doc.rust-lang.org/nightly/nightly-rustc/rustc_ast/ast/enum.TyKind.html#variant.Typeof</a></p>



<a name="194445748"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194445748" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194445748">(Apr 17 2020 at 14:12)</a>:</h4>
<p>heh</p>



<a name="194445771"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194445771" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194445771">(Apr 17 2020 at 14:12)</a>:</h4>
<p><code>typeof</code></p>



<a name="194445818"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194445818" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194445818">(Apr 17 2020 at 14:12)</a>:</h4>
<p>the funny thing is it would also be very easy to finish the implementation thereof</p>



<a name="194445838"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194445838" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194445838">(Apr 17 2020 at 14:12)</a>:</h4>
<p>but nobody made an RFC AFAIK</p>



<a name="194445891"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194445891" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194445891">(Apr 17 2020 at 14:12)</a>:</h4>
<p>maybe we should make it error, printing the type</p>



<a name="194446357"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194446357" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194446357">(Apr 17 2020 at 14:16)</a>:</h4>
<p>This? <a href="https://github.com/rust-lang/rust/issues/3228" title="https://github.com/rust-lang/rust/issues/3228">https://github.com/rust-lang/rust/issues/3228</a></p>



<a name="194446386"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194446386" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194446386">(Apr 17 2020 at 14:16)</a>:</h4>
<p>lmao I don't remember seeing that</p>



<a name="194446501"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194446501" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194446501">(Apr 17 2020 at 14:17)</a>:</h4>
<p>wouldn't that always be kind of a mess due to variance?</p>



<a name="194447352"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194447352" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194447352">(Apr 17 2020 at 14:22)</a>:</h4>
<p>funny you should say that</p>



<a name="194447379"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194447379" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194447379">(Apr 17 2020 at 14:22)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> raised a similar point recently :P</p>



<a name="194447453"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194447453" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194447453">(Apr 17 2020 at 14:23)</a>:</h4>
<p>although no, not variance, outlives</p>



<a name="194467919"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194467919" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194467919">(Apr 17 2020 at 16:43)</a>:</h4>
<p><span class="user-mention" data-user-id="121053">@varkor</span>  How can I reliably get the relevant <code>Generics</code> for a const argument.  (don't care about potential cycle errors there)</p>
<p>I currently try <code>tcx.generics_of(tcx.hir().local_def_id(tcx.hir().get_parent_node(tcx.hir().as_local_hir_id(def_id).unwrap())))</code><br>
But some parent nodes don't have a associated <code>DefId</code>, which causes <code>local_def_id</code> to panic</p>



<a name="194468165"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194468165" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194468165">(Apr 17 2020 at 16:45)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@Bastian Kauschke</span> literally just <code>tcx.generics_of(def_id)</code></p>



<a name="194468301"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194468301" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194468301">(Apr 17 2020 at 16:46)</a>:</h4>
<p>assuming the <code>def_id</code> is of an <code>AnonConst</code></p>



<a name="194468324"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194468324" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194468324">(Apr 17 2020 at 16:46)</a>:</h4>
<p>hhhhhhhhhhhhhh</p>



<a name="194468328"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194468328" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194468328">(Apr 17 2020 at 16:46)</a>:</h4>
<p>ok</p>



<a name="194468848"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194468848" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194468848">(Apr 17 2020 at 16:50)</a>:</h4>
<p>sorry for always being slow to respond: I don't keep Zulip open and so I only spot messages every so often when I check my phone :P</p>



<a name="194469116"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194469116" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194469116">(Apr 17 2020 at 16:52)</a>:</h4>
<p>no worries <span class="user-mention" data-user-id="119009">@eddyb</span> Is just too fast <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span></p>



<a name="194474609"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194474609" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194474609">(Apr 17 2020 at 17:33)</a>:</h4>
<p>apparently <code>tcx.generics_of(def_id)</code> doesn't work in all cases. We previously used <code>Res</code> to get a correct <code>DefId</code>.<br>
<a href="https://github.com/rust-lang/rust/blob/8d67f576b56e8fc98a31123e5963f8d00e40611c/src/librustc_typeck/collect/type_of.rs#L263-L277" title="https://github.com/rust-lang/rust/blob/8d67f576b56e8fc98a31123e5963f8d00e40611c/src/librustc_typeck/collect/type_of.rs#L263-L277">https://github.com/rust-lang/rust/blob/8d67f576b56e8fc98a31123e5963f8d00e40611c/src/librustc_typeck/collect/type_of.rs#L263-L277</a></p>
<p>What exactly is the use of<code>Res</code> here. I worked on this code for a few times and still have no idea tbh <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="194474732"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194474732" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194474732">(Apr 17 2020 at 17:34)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@Bastian Kauschke</span> oh that's a completely different thing</p>



<a name="194474735"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194474735" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194474735">(Apr 17 2020 at 17:34)</a>:</h4>
<p>Why do we have to use the <code>parent_did</code> for <code>DefKind::Ctor</code></p>



<a name="194474744"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194474744" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194474744">(Apr 17 2020 at 17:34)</a>:</h4>
<p><code>res</code> is the resolution</p>



<a name="194474753"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194474753" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194474753">(Apr 17 2020 at 17:34)</a>:</h4>
<p><em>of the path</em></p>



<a name="194474781"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194474781" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194474781">(Apr 17 2020 at 17:34)</a>:</h4>
<p>so the <code>generics_of</code> is for the thing that <em>takes</em> const generics</p>



<a name="194474862"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194474862" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194474862">(Apr 17 2020 at 17:35)</a>:</h4>
<p>the parent for the ctor is because the params are on e.g. on the <code>struct</code></p>



<a name="194474890"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194474890" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194474890">(Apr 17 2020 at 17:35)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@Bastian Kauschke</span> earlier I thought you were asking about getting the generics in scope of the anon const expression</p>



<a name="194474902"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194474902" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194474902">(Apr 17 2020 at 17:35)</a>:</h4>
<p>not what it's passed to</p>



<a name="194474917"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194474917" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194474917">(Apr 17 2020 at 17:35)</a>:</h4>
<p>the latter depends on what you're passing it to</p>



<a name="194474987"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194474987" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194474987">(Apr 17 2020 at 17:36)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="kd">let</span><span class="w"> </span><span class="n">a</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">foo</span>::<span class="o">&lt;</span><span class="mi">7</span><span class="o">&gt;</span><span class="p">();</span><span class="w"></span>
<span class="w">              </span><span class="o">^</span><span class="w"> </span><span class="n">I</span><span class="w"> </span><span class="n">want</span><span class="w"> </span><span class="n">to</span><span class="w"> </span><span class="n">get</span><span class="w"> </span><span class="err">`</span><span class="n">N</span><span class="err">`</span><span class="w"> </span><span class="n">here</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">foo</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="p">()</span><span class="w"></span>
<span class="w">             </span><span class="o">^</span><span class="w"> </span><span class="n">this</span><span class="w"> </span><span class="err">`</span><span class="n">DefId</span><span class="err">`</span><span class="w"></span>
</pre></div>



<a name="194474993"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194474993" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194474993">(Apr 17 2020 at 17:36)</a>:</h4>
<p>every place calling <code>to_const</code> or whatever has to supply its own depending on where the const expression is</p>



<a name="194475062"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194475062" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194475062">(Apr 17 2020 at 17:37)</a>:</h4>
<p>right so that requires you to figure out where the const args &lt;-&gt; parameters matching is checked</p>



<a name="194475126"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194475126" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194475126">(Apr 17 2020 at 17:37)</a>:</h4>
<p>basically the same place that errors when the number of generic args doesn't match the number of parameters</p>



<a name="194475138"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194475138" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194475138">(Apr 17 2020 at 17:37)</a>:</h4>
<p>and likely calls <code>to_const</code></p>



<a name="194475652"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194475652" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194475652">(Apr 17 2020 at 17:42)</a>:</h4>
<p>I previously used <a href="https://github.com/rust-lang/rust/blob/99c18ab8a98e1b171489cb2e0a06ea5471b9c633/src/librustc_typeck/collect/type_of.rs#L246-L272" title="https://github.com/rust-lang/rust/blob/99c18ab8a98e1b171489cb2e0a06ea5471b9c633/src/librustc_typeck/collect/type_of.rs#L246-L272">https://github.com/rust-lang/rust/blob/99c18ab8a98e1b171489cb2e0a06ea5471b9c633/src/librustc_typeck/collect/type_of.rs#L246-L272</a></p>
<p>The get the type of the param, can this be adjusted to get its DefId?</p>



<a name="194475700"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194475700" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194475700">(Apr 17 2020 at 17:42)</a>:</h4>
<p>heh</p>



<a name="194475805"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194475805" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194475805">(Apr 17 2020 at 17:43)</a>:</h4>
<p><span class="user-mention silent" data-user-id="119009">eddyb</span> <a href="#narrow/stream/131828-t-compiler/topic/lazy.20normalization.20example/near/194475126" title="#narrow/stream/131828-t-compiler/topic/lazy.20normalization.20example/near/194475126">said</a>:</p>
<blockquote>
<p>basically the same place that errors when the number of generic args doesn't match the number of parameters</p>
</blockquote>
<p>that's <code>check_generic_arg_count</code>, though I don't think it uses <code>to_const</code></p>



<a name="194475822"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194475822" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194475822">(Apr 17 2020 at 17:43)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@Bastian Kauschke</span> sort of, but you need to get the <code>DefId</code> of the thing the segment refers to. <code>type_relative_defs</code> is I think the right table</p>



<a name="194475912"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194475912" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194475912">(Apr 17 2020 at 17:44)</a>:</h4>
<p>there's something like <code>qpath_res</code> maybe?</p>



<a name="194476052"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194476052" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194476052">(Apr 17 2020 at 17:45)</a>:</h4>
<p><a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TypeckTables.html#structfield.type_dependent_defs" title="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TypeckTables.html#structfield.type_dependent_defs">https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TypeckTables.html#structfield.type_dependent_defs</a></p>



<a name="194476059"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194476059" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194476059">(Apr 17 2020 at 17:45)</a>:</h4>
<p>?</p>



<a name="194476069"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194476069" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194476069">(Apr 17 2020 at 17:45)</a>:</h4>
<p>yeah</p>



<a name="194497996"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194497996" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194497996">(Apr 17 2020 at 20:50)</a>:</h4>
<p>Thanks <span aria-label="heart" class="emoji emoji-2764" role="img" title="heart">:heart:</span> I believe I now have a working concept!</p>
<p>I fear the error messages though</p>
<div class="codehilite"><pre><span></span>warning: the feature `const_generics` is incomplete and may cause the compiler to crash
  --&gt; /home/programming/rust/src/test/ui/__check/issue-61936.rs:2:12
   |
LL | #![feature(const_generics)]
   |            ^^^^^^^^^^^^^^
   |
   = note: `#[warn(incomplete_features)]` on by default

error[E0391]: cycle detected when type-checking `main`
  --&gt; /home/programming/rust/src/test/ui/__check/issue-61936.rs:41:1
   |
LL | fn main() {
   | ^^^^^^^^^
   |
note: ...which requires const-evaluating + checking `main::{{constant}}#0`...
  --&gt; /home/programming/rust/src/test/ui/__check/issue-61936.rs:44:47
   |
LL |     for array in v.as_slice().array_windows::&lt;FOUR&gt;() {
   |                                               ^^^^
note: ...which requires const-evaluating + checking `main::{{constant}}#0`...
  --&gt; /home/programming/rust/src/test/ui/__check/issue-61936.rs:44:47
   |
LL |     for array in v.as_slice().array_windows::&lt;FOUR&gt;() {
   |                                               ^^^^
note: ...which requires const-evaluating `main::{{constant}}#0`...
  --&gt; /home/programming/rust/src/test/ui/__check/issue-61936.rs:44:47
   |
LL |     for array in v.as_slice().array_windows::&lt;FOUR&gt;() {
   |                                               ^^^^
note: ...which requires optimizing MIR...
  --&gt; /home/programming/rust/src/test/ui/__check/issue-61936.rs:44:47
   |
LL |     for array in v.as_slice().array_windows::&lt;FOUR&gt;() {
   |                                               ^^^^
note: ...which requires borrow-checking `main::{{constant}}#0`...
  --&gt; /home/programming/rust/src/test/ui/__check/issue-61936.rs:44:47
   |
LL |     for array in v.as_slice().array_windows::&lt;FOUR&gt;() {
   |                                               ^^^^
note: ...which requires processing `main::{{constant}}#0`...
  --&gt; /home/programming/rust/src/test/ui/__check/issue-61936.rs:44:47
   |
LL |     for array in v.as_slice().array_windows::&lt;FOUR&gt;() {
   |                                               ^^^^
note: ...which requires const checking `main::{{constant}}#0`...
  --&gt; /home/programming/rust/src/test/ui/__check/issue-61936.rs:44:47
   |
LL |     for array in v.as_slice().array_windows::&lt;FOUR&gt;() {
   |                                               ^^^^
note: ...which requires processing `main::{{constant}}#0`...
  --&gt; /home/programming/rust/src/test/ui/__check/issue-61936.rs:44:47
   |
LL |     for array in v.as_slice().array_windows::&lt;FOUR&gt;() {
   |                                               ^^^^
note: ...which requires unsafety-checking `main::{{constant}}#0`...
  --&gt; /home/programming/rust/src/test/ui/__check/issue-61936.rs:44:47
   |
LL |     for array in v.as_slice().array_windows::&lt;FOUR&gt;() {
   |                                               ^^^^
note: ...which requires building MIR for...
  --&gt; /home/programming/rust/src/test/ui/__check/issue-61936.rs:44:47
   |
LL |     for array in v.as_slice().array_windows::&lt;FOUR&gt;() {
   |                                               ^^^^
note: ...which requires type-checking `main::{{constant}}#0`...
  --&gt; /home/programming/rust/src/test/ui/__check/issue-61936.rs:44:47
   |
LL |     for array in v.as_slice().array_windows::&lt;FOUR&gt;() {
   |                                               ^^^^
note: ...which requires processing `main::{{constant}}#0`...
  --&gt; /home/programming/rust/src/test/ui/__check/issue-61936.rs:44:47
   |
LL |     for array in v.as_slice().array_windows::&lt;FOUR&gt;() {
   |                                               ^^^^
   = note: ...which again requires type-checking `main`, completing the cycle
   = note: cycle used when type-checking all item bodies
</pre></div>



<a name="194545303"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194545303" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194545303">(Apr 18 2020 at 13:43)</a>:</h4>
<p>A UI test requires the line in the error message and I don't know why <a href="https://github.com/rust-lang/rust/blob/86f765faac81d71192fa3df5466beec556b7bb58/src/test/ui/recursion/issue-26548-recursion-via-normalize.rs#L11" title="https://github.com/rust-lang/rust/blob/86f765faac81d71192fa3df5466beec556b7bb58/src/test/ui/recursion/issue-26548-recursion-via-normalize.rs#L11">https://github.com/rust-lang/rust/blob/86f765faac81d71192fa3df5466beec556b7bb58/src/test/ui/recursion/issue-26548-recursion-via-normalize.rs#L11</a></p>



<a name="194545407"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194545407" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194545407">(Apr 18 2020 at 13:44)</a>:</h4>
<p>if we already have cycle errors, another one doesn't seem particularly harmful, as long as this isn't incorrect</p>



<a name="194545430"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194545430" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194545430">(Apr 18 2020 at 13:45)</a>:</h4>
<p>My problem is that <code>//~ NOTE 11:1: 11:10: cycle used when </code>main<code>[None]</code> is required</p>



<a name="194545434"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194545434" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194545434">(Apr 18 2020 at 13:45)</a>:</h4>
<p><code>//~ NOTE cycle used when main[None]</code> does not detect this error</p>



<a name="194545439"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194545439" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194545439">(Apr 18 2020 at 13:46)</a>:</h4>
<p>stderr seems normal </p>
<div class="codehilite"><pre><span></span>error[E0391]: cycle detected when computing layout of `std::option::Option&lt;S&gt;`
   |
   = note: ...which requires computing layout of `S`...
   = note: ...which again requires computing layout of `std::option::Option&lt;S&gt;`, completing the cycle
note: cycle used when `main`[None]
  --&gt; $DIR/issue-26548-recursion-via-normalize.rs:11:1
   |
LL | fn main() {
   | ^^^^^^^^^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0391`.
</pre></div>



<a name="194545564"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194545564" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194545564">(Apr 18 2020 at 13:48)</a>:</h4>
<p>oh, weird</p>



<a name="194545652"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194545652" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194545652">(Apr 18 2020 at 13:51)</a>:</h4>
<p>nm, it suddently works... did I mess up a whitespace or something? <span aria-label="surrender" class="emoji emoji-1f3f3" role="img" title="surrender">:surrender:</span></p>



<a name="194546601"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194546601" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194546601">(Apr 18 2020 at 14:12)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/blob/dc0823a9a766ee6f72f5a7b013d7cb8288bf7b12/src/librustc_mir/borrow_check/mod.rs#L92-L100" title="https://github.com/rust-lang/rust/blob/dc0823a9a766ee6f72f5a7b013d7cb8288bf7b12/src/librustc_mir/borrow_check/mod.rs#L92-L100">https://github.com/rust-lang/rust/blob/dc0823a9a766ee6f72f5a7b013d7cb8288bf7b12/src/librustc_mir/borrow_check/mod.rs#L92-L100</a></p>
<p><span class="user-mention" data-user-id="121053">@varkor</span> I currently check in all queries if the <code>DefId</code> is a const arg and then call the same query with the corresponding param <code>DefId</code>.<br>
This causes longer cycles (on potentially valid cycle errors)  than necessary though. I could try and move this check to the callsite instead, but I fear that this is even more complex</p>



<a name="194546631"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194546631" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194546631">(Apr 18 2020 at 14:13)</a>:</h4>
<p>It's worse enough to review this PR as is <span aria-label="unamused" class="emoji emoji-1f612" role="img" title="unamused">:unamused:</span></p>



<a name="194546730"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194546730" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194546730">(Apr 18 2020 at 14:15)</a>:</h4>
<p>See <a href="https://github.com/rust-lang/rust/pull/71154/commits/dc0823a9a766ee6f72f5a7b013d7cb8288bf7b12" title="https://github.com/rust-lang/rust/pull/71154/commits/dc0823a9a766ee6f72f5a7b013d7cb8288bf7b12">https://github.com/rust-lang/rust/pull/71154/commits/dc0823a9a766ee6f72f5a7b013d7cb8288bf7b12</a></p>



<a name="194547042"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194547042" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194547042">(Apr 18 2020 at 14:22)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@Bastian Kauschke</span>: I shall try to take a look soon :)</p>



<a name="194547482"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194547482" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194547482">(Apr 18 2020 at 14:33)</a>:</h4>
<p><span class="user-mention" data-user-id="121053">@varkor</span> btw if the PR isn't marked as Draft, please do</p>



<a name="194547486"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194547486" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194547486">(Apr 18 2020 at 14:33)</a>:</h4>
<p>it is <span aria-label="+1" class="emoji emoji-1f44d" role="img" title="+1">:+1:</span></p>



<a name="194547498"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194547498" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194547498">(Apr 18 2020 at 14:33)</a>:</h4>
<p>I bet when I finally get to it I will regret taking the time to get to it lol</p>



<a name="194547561"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194547561" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194547561">(Apr 18 2020 at 14:34)</a>:</h4>
<p>It is still marked as draft, will take a few more hours for me to get through this <a href="/user_uploads/4715/1e1Nmw9_HN7zpqne3KAw6rm0/Screenshot-from-2020-04-18-16-33-33.png" title="Screenshot-from-2020-04-18-16-33-33.png">Screenshot-from-2020-04-18-16-33-33.png</a></p>
<div class="message_inline_image"><a href="/user_uploads/4715/1e1Nmw9_HN7zpqne3KAw6rm0/Screenshot-from-2020-04-18-16-33-33.png" title="Screenshot-from-2020-04-18-16-33-33.png"><img src="/user_uploads/4715/1e1Nmw9_HN7zpqne3KAw6rm0/Screenshot-from-2020-04-18-16-33-33.png"></a></div>



<a name="194547576"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194547576" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194547576">(Apr 18 2020 at 14:34)</a>:</h4>
<blockquote>
<p>I bet when I finally get to it I will regret taking the time to get to it lol</p>
</blockquote>
<p>It is horrible</p>



<a name="194547762"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194547762" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194547762">(Apr 18 2020 at 14:39)</a>:</h4>
<p>lol</p>



<a name="194547771"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194547771" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194547771">(Apr 18 2020 at 14:39)</a>:</h4>
<p>I love reviewing 1k-line PRs :)</p>



<a name="194547941"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194547941" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194547941">(Apr 18 2020 at 14:43)</a>:</h4>
<p><code>crate fn mir_built(tcx: TyCtxt&lt;'_&gt;, (def_id, param_def_id): (DefId, Option&lt;DefId&gt;)) -&gt; &amp;ty::steal::Steal&lt;BodyAndCache&lt;'_&gt;&gt; {</code><br>
Why doesn't rustfmt split this line :O</p>



<a name="194548518"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194548518" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194548518">(Apr 18 2020 at 14:56)</a>:</h4>
<p>rustfmt is imperfect</p>



<a name="194549163"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194549163" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194549163">(Apr 18 2020 at 15:10)</a>:</h4>
<p>Some tips for cleaning up this commit history? <a href="/user_uploads/4715/NSe5aZama0JMBx6w4hiD1Mei/Screenshot-from-2020-04-18-17-08-29.png" title="Screenshot-from-2020-04-18-17-08-29.png">Screenshot-from-2020-04-18-17-08-29.png</a> </p>
<div class="message_inline_image"><a href="/user_uploads/4715/NSe5aZama0JMBx6w4hiD1Mei/Screenshot-from-2020-04-18-17-08-29.png" title="Screenshot-from-2020-04-18-17-08-29.png"><img src="/user_uploads/4715/NSe5aZama0JMBx6w4hiD1Mei/Screenshot-from-2020-04-18-17-08-29.png"></a></div><p>The PR should now be at least somewhat coherent <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span></p>



<a name="194550066"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194550066" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194550066">(Apr 18 2020 at 15:28)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/pull/71154" title="https://github.com/rust-lang/rust/pull/71154">https://github.com/rust-lang/rust/pull/71154</a> no draft no more</p>



<a name="194550318"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194550318" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194550318">(Apr 18 2020 at 15:34)</a>:</h4>
<p>lmao <a href="https://github.com/rust-lang/rust/pull/71154#issuecomment-613709634" title="https://github.com/rust-lang/rust/pull/71154#issuecomment-613709634">https://github.com/rust-lang/rust/pull/71154#issuecomment-613709634</a></p>



<a name="194550321"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194550321" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194550321">(Apr 18 2020 at 15:34)</a>:</h4>
<p>I will do that again</p>



<a name="194550326"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194550326" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194550326">(Apr 18 2020 at 15:34)</a>:</h4>
<p>please keep it "draft" until I can review</p>



<a name="194550348"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194550348" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194550348">(Apr 18 2020 at 15:35)</a>:</h4>
<blockquote>
<p>btw if the PR isn't marked as Draft, please do</p>
</blockquote>
<p>you meant if it isn't marked as Draft, please mark it as such?</p>



<a name="194550373"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194550373" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194550373">(Apr 18 2020 at 15:35)</a>:</h4>
<p>Not "if it isn't marked as Draft, please review it soon"</p>



<a name="194550381"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194550381" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194550381">(Apr 18 2020 at 15:35)</a>:</h4>
<p>argh, the former</p>



<a name="194550384"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194550384" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194550384">(Apr 18 2020 at 15:35)</a>:</h4>
<p><span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="194550422"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194550422" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194550422">(Apr 18 2020 at 15:36)</a>:</h4>
<p>/me shouldn't use terse English constructs</p>



<a name="194550430"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194550430" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194550430">(Apr 18 2020 at 15:36)</a>:</h4>
<p>they sound fancy but they're ambiguous for everyone other than the person who wrote them</p>



<a name="194552505"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194552505" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194552505">(Apr 18 2020 at 16:24)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216206">Bastian Kauschke</span> <a href="#narrow/stream/131828-t-compiler/topic/lazy.20normalization.20example/near/194549163" title="#narrow/stream/131828-t-compiler/topic/lazy.20normalization.20example/near/194549163">said</a>:</p>
<blockquote>
<p>Some tips for cleaning up this commit history? <a href="/user_uploads/4715/NSe5aZama0JMBx6w4hiD1Mei/Screenshot-from-2020-04-18-17-08-29.png" title="Screenshot-from-2020-04-18-17-08-29.png">Screenshot-from-2020-04-18-17-08-29.png</a> </p>
<p>The PR should now be at least somewhat coherent <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span></p>
</blockquote>
<p>You could squash commits together, especially commits that are just random cleanup or fixes (see <code>git rebase -i</code>)</p>



<a name="194553106"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194553106" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194553106">(Apr 18 2020 at 16:38)</a>:</h4>
<p><span aria-label="thumbs up" class="emoji emoji-1f44d" role="img" title="thumbs up">:thumbs_up:</span></p>



<a name="194553218"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194553218" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194553218">(Apr 18 2020 at 16:41)</a>:</h4>
<p>My main problem is that I probably will end up with one commit containing 500 lines, as I don't know how to split it into selfcontained segments.</p>
<p>I only changes a few lines per file. Is it better or worse to split it for each crate (i.e. change librustc_mir and then in another commit librustc_typeck) even if these individual commits don't compile?</p>



<a name="194553548"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194553548" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194553548">(Apr 18 2020 at 16:49)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@Bastian Kauschke</span> without looking at the PR, it's hard to say. If all the changes are logically the same sort, it might be reasonable to just squash into one big commit. If there are smaller self-contained commits that could be separated out, that could also be good. Also, if eddyb (as the reviewer) has a preference, you should do that.</p>



<a name="194553601"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194553601" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194553601">(Apr 18 2020 at 16:50)</a>:</h4>
<p>Another trick is to <code>git reset</code> back to the head so all of the changes are unstaged. You can then do <code>git add -p</code> to stage just the parts you want and rebuild your commit history however you want.</p>



<a name="194590251"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/lazy%20normalization%20example/near/194590251" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/lazy.20normalization.20example.html#194590251">(Apr 19 2020 at 10:21)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/pull/71154" title="https://github.com/rust-lang/rust/pull/71154">https://github.com/rust-lang/rust/pull/71154</a> currently still fails when using multiple crates.</p>
<p>As <code>typeck_tables</code> now doesn't call <code>type_of(const_arg)</code> anymore, other crates ,ay call <code>type_of</code>[more accurately <code>const_param_of</code>) which must not happen, as this query requires the <code>local_hir_id</code>. <a href="https://github.com/rust-lang/rust/blob/c94d6b5e1807b6487c676a75e4485f9becda8e2e/src/librustc_typeck/collect/type_of.rs#L24" title="https://github.com/rust-lang/rust/blob/c94d6b5e1807b6487c676a75e4485f9becda8e2e/src/librustc_typeck/collect/type_of.rs#L24">https://github.com/rust-lang/rust/blob/c94d6b5e1807b6487c676a75e4485f9becda8e2e/src/librustc_typeck/collect/type_of.rs#L24</a></p>
<p>Is there a way to get the corresponding generic parameter for a const argument of an external crate?</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>